home *** CD-ROM | disk | FTP | other *** search
/ BBS Toolkit / BBS Toolkit.iso / wildcat / addbad10.zip / ADDBAD.BAS next >
BASIC Source File  |  1992-08-15  |  3KB  |  71 lines

  1. '##########################################################################
  2. '## ADDBAD.BAS                                                           ##
  3. '## BASIC 7.1 source code by Tim Kilgore                                 ##
  4. '## Dated: 08/15/92                                                      ##
  5. '##                                                                      ##
  6. '## Updated:                                                             ##
  7. '## By:                                                                  ##
  8. '##                                                                      ##
  9. '## Lines using QBX-specific commands are noted with a "QBX" comment to  ##
  10. '## facilitate conversions to QuickBASIC or QBasic.                      ##
  11. '##                                                                      ##
  12. '##########################################################################
  13.  
  14. DEFINT A-Z
  15. DECLARE SUB Reverse (ST$)
  16.  
  17. PRINT : PRINT : PRINT "AddBad v1.0, released into the Public Domain by Tim Kilgore"
  18.  
  19. work$ = COMMAND$                                '%1 passed to SCANFILE.BAT
  20. found = LEN(DIR$(work$))                        'Has the file been moved? (BAD)    QBX
  21. IF found = 0 OR LEN(work$) = 0 OR INSTR(work$, ".GIF") THEN
  22.    PRINT "Nothing to do.  Done."
  23.    END
  24. END IF
  25.  
  26. Reverse work$                                   'Reverse the string and
  27. IF INSTR(work$, "\") THEN                       'find the file name.
  28.    work$ = LEFT$(work$, INSTR(work$, "\") - 1)
  29. END IF
  30. Reverse work$                                   'Un-reverse the filename and
  31. IF INSTR(work$, ".") THEN                       'search for an extension.
  32.    work$ = LEFT$(work$, INSTR(work$, ".")) + "*"  'Change extension to "*"
  33. END IF
  34.  
  35. TOP:                                            'For error handling
  36. ON ERROR GOTO Trap                              'Activate error handling
  37. OPEN "BADFILES.LST" FOR APPEND LOCK WRITE AS #1 'Open BADFILES
  38. ON ERROR GOTO 0                                 'De-activate error handling
  39. PRINT #1, work$                                 'Dump the file name to disk
  40. CLOSE                                           'Close our files.
  41. PRINT work$ + " added to " + CURDIR$; "\BADFILES.LST.  Done!";                 'QBX
  42.  
  43. END                                             'Gone.
  44.  
  45.  
  46. '##########################################################################
  47.  
  48. Trap:                                           'Error trapping...
  49. ecount = ecount + 1                             'Keep count of return trips
  50. IF ecount = 6 THEN                              'Tried to open for 5 seconds, gone
  51.    PRINT : PRINT "Unable to open BADFILES.LST.  Terminating."
  52.    END
  53. END IF
  54. SLEEP 1                                         'Wait for file to become available
  55. GOTO TOP                                        'Return and try to open file again
  56.  
  57. '##########################################################################
  58.  
  59. SUB Reverse (ST$)
  60.  
  61. 'This SUB reverses any string sent to it.  Handy at times...
  62.  
  63. FOR a = LEN(ST$) TO 1 STEP -1
  64.    tmp$ = tmp$ + MID$(ST$, a, 1)
  65. NEXT a
  66.  
  67. ST$ = tmp$
  68.  
  69. END SUB
  70.  
  71.